package top.luoyuanxiang.mqtt.kafka;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

/**
 * Kafka生产者
 *
 * @author luoyuanxiang
 */
@Component
public class KafkaProducer {

     private final KafkaTemplate<String, String> kafkaTemplate;

       public KafkaProducer(KafkaTemplate<String, String> kafkaTemplate) {
           this.kafkaTemplate = kafkaTemplate;
       }

       public void sendMessage(String topic, String message) {
           kafkaTemplate.send(topic, message);
       }
}
